package structure;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class RLECompressedFile {
	private String fileName;
	private FileOutputStream fos;
	
	public RLECompressedFile(String fileName) {
		this.fileName = fileName;
		try {
			fos = new FileOutputStream(fileName);
		}
		catch(FileNotFoundException ex){
			System.out.println("Nie znaleziono pliku!!!");
		}
	}
	
	public void addBinary(byte[] binary){
		try {
			fos.write(binary);
		}
		catch(IOException ioe){
			System.out.println("Error");
			ioe.printStackTrace();
		}
	}
	
	public void finish(){
		try {
			fos.close();
		}
		catch(Exception e) {
			System.out.print("Problem with closing file!!!");
		}
	}
	
	public File getFile (){
		return new File (fileName);
	}
}
